﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 七天入手上位机第一个项目
{
    public partial class Temperature : UserControl
    {
        public Temperature()
        {
            InitializeComponent();
        }

        private string tempName = "名称";
        [Browsable(true)]
        [Description("设置或获取温度的名称")]
        public string TempName
        {
            get { return tempName; }
            set
            {
                tempName = value;
                this.lbl_Name.Text = tempName;
            }
        }

        private float maxValue=100f;
        [Browsable(true)]
        [Description("设置或获取温度的最大值")]
        public float MaxValue
        {
            get { return maxValue; }
            set
            {
                maxValue = value;

                this.th.MaxValue = value;
            }
        }
        private float minValue=0f;
        [Browsable(true)]
        [Description("设置或获取温度的最小值")]
        public float MinValue
        {
            get { return minValue; }
            set
            {
                minValue = value;

                this.th.MinValue = value;
            }
        }

        private float intervalValue = 0f;
        [Browsable(true)]
        [Description("设置或获取间隔")]
        public float IntervalValue
        {
            get { return intervalValue; }
            set
            {
                intervalValue = value;

                this.th.IntervalValue = value;
            }
        }

        private string value = "0.0℃";
        /// <summary>
        /// 表示设备的值的属性
        /// </summary>
        [Browsable(true)]
        [Description("设置或获取设备的值")]
        public string Value
        {
            get { return this.value; }
            set
            {
                this.value = value;
                // 将字符串值转换为浮点数，并设置给th的Value属性
                float f = 0f;
                // 尝试将字符串转换为浮点数
                float.TryParse(value, out f);
                this.th.Value = f;
                // 同时将值赋给lbl_th1并加上温度单位"℃"
                this.lbl_th1.Text = value.ToString() + "℃";
            }
        }




    }

}
